//3d地球
export function earth(myChart) {
    var ROOT_PATH = 'https://cdn.jsdelivr.net/gh/apache/echarts-website@asf-site/examples';
    var option;

    $.getJSON(ROOT_PATH + '/data-gl/asset/data/flights.json', function(data) {
        function getAirportCoord(idx) {
            return [data.airports[idx][3], data.airports[idx][4]];
        }
        var routes = data.routes.map(function(airline) {
            return [getAirportCoord(airline[1]), getAirportCoord(airline[2])];
        });
        myChart.setOption({
            // backgroundColor: '#000',
            globe: {
                baseTexture: ROOT_PATH + '/data-gl/asset/world.topo.bathy.200401.jpg',
                heightTexture: ROOT_PATH + '/data-gl/asset/bathymetry_bw_composite_4k.jpg',
                shading: 'lambert',
                light: {
                    ambient: {
                        intensity: 1
                    },
                    main: {
                        intensity: 1
                    }
                },
                viewControl: {
                    projection: 'orthographic',
                    orthographicSize: 250, //控制地图大小
                    maxOrthographicSize: 250,
                    minOrthographicSize: 250,
                    autoRotate: true,
                    alpha: 25,
                    beta: 100,
                }
            },
            series: {
                type: 'lines3D',
                coordinateSystem: 'globe',
                blendMode: 'lighter',
                lineStyle: {
                    width: 1,
                    color: 'rgb(50, 50, 150)',
                    opacity: 0.1
                },
                data: routes
            }
        });
    });
    // 把配置给实例对象
    option && myChart.setOption(option);
    //让图表跟随屏幕自适应
    window.addEventListener("resize", function() {
        myChart.resize();
    });
}